import { _decorator, Component, director, Node, ProgressBar, resources } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('LoadingManager')
export class LoadingManager extends Component {
    @property(ProgressBar)
    progressBar: ProgressBar = null

    //预加载资源
    onLoad() {
        resources.preloadDir("texture", (cur, total) => {
            this.progressBar.progress = cur / total
        }, (err, res) => {
            if (err) {
                console.log(err)
            } else {
                director.loadScene("MainScene")
            }
        })
    }

}


